﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
@* 添加人员 *@
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>




<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet">
</head>
<body>
    
    <form class="layui-form" >
        <div class="layui-form-item">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <h3 style="text-align:center">增加人员</h3>
                    <h2>基本信息</h2>
                    <hr class="layui-border-green">
                    <table>
                        <tr>
                            <td>
                                <label class="layui-form-label">姓名</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" id="persName" placeholder="请输入姓名" class="layui-input">
                                </div>
                            </td>
                            <td>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">性别</label>
                                    <div class="layui-input-block">
                                        <input type="radio" name="persSex" value="男" title="男">
                                        <input type="radio" name="persSex" value="女" title="女">

                                    </div>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">证件类型</label>
                                    <div class="layui-input-block">
                                        <select id="persCardType" lay-filter="aihao">
                                            <option value="">请选择证件类型</option>
                                            <option value="身份证">身份证</option>
                                            <option value="护照">护照</option>
                                            <option value="军官证">军官证</option>
                                            <option value="士兵证">士兵证</option>
                                            <option value="港澳台往来通行证">港澳台往来通行证</option>
                                            <option value="警官证">警官证</option>
                                            <option value="外国人永久居留证">外国人永久居留证</option>
                                            <option value="边民出入通行证">边民出入通行证</option>
                                            <option value="其他">其他</option>
                                        </select>
                                    </div>
                                </div>
                            </td>
                            <td>
                                <input type="text" id="persCard" placeholder="（必填）" class="layui-input">
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label class="layui-form-label">联系电话</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" id="persPhone" placeholder="请输入联系方式" class="layui-input">
                                </div>
                            </td>
                            <td>
                                <label class="layui-form-label">电子邮箱</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" id="persEmail" class="layui-input">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label class="layui-form-label">毕业院校</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" id="persCollege" placeholder="请输入毕业院校" class="layui-input">
                                </div>
                            </td>
                            <td>
                                <label class="layui-form-label">学历</label>
                                <div class="layui-input-block">
                                    <select id="education" lay-filter="aihao">
                                        <option value="">请选择学历</option>
                                        <option value="博士">博士</option>
                                        <option value="硕士">硕士</option>
                                        <option value="本科">本科</option>
                                        <option value="大专">大专</option>
                                        <option value="中专">中专</option>
                                        <option value="高中">高中</option>
                                        <option value="初中">初中</option>
                                        <option value="小学">小学</option>
                                        <option value="其他">其他</option>
                                    </select>
                                </div>
                            </td>
                        </tr>
                    </table>
                    
                    <h2>入职信息</h2>
                    <hr class="layui-border-green">
                    <table>
                        <tr>
                            <td>
                                <label class="layui-form-label">单位</label>
                                <div class="layui-input-block">
                                    <select id="enterpriseId" lay-filter="aihao">
                                        <option value="-1">请选择单位</option>
                                        <option value="1">宏光养羊</option>
                                        <option value="2">黄赛超养羊</option>
                                        
                                        
                                    </select>
                                </div>
                            </td>
                            <td>
                                <label class="layui-form-label">员工状态</label>
                                <div class="layui-input-block">
                                    <select id="staffState" lay-filter="aihao">
                                        <option value="">请选择状态</option>
                                        <option value="博士">试用员工</option>
                                        <option value="硕士">在职员工</option>
                                        <option value="本科">实习员工</option>
                                        <option value="大专">临时工人</option>
                                        <option value="中专">调值员工</option>
                                        <option value="高中">专家顾问</option>
                                        <option value="初中">返聘人员</option>
                                        
                                    </select>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label class="layui-form-label">部门</label>
                                <div class="layui-input-block">
                                    <select  id="departmentId" lay-filter="aihao">
                                        <option value="">请选择</option>
                                        <option value="1">测试部</option>
                                        <option value="2">秘书部</option>
                                        <option value="3">组织部</option>
                                    </select>
                                </div>
                            </td>
                            <td>
                                
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label class="layui-form-label">入职日期</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="date" id="persEntry" lay-verify="date" autocomplete="off" class="layui-input">
                                </div>
                            </td>
                            <td>
                                <label class="layui-form-label">转正日期</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="date" id="persRegular" lay-verify="date" autocomplete="off" class="layui-input">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label class="layui-form-label">职务</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" id="persFunction" placeholder="请输入职务" class="layui-input">
                                </div>
                            </td>
                            <td>
                                <label class="layui-form-label">岗位</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" id="presTrain" placeholder="请输入岗位" class="layui-input">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label class="layui-form-label">认识级别</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" id="presLevel" placeholder="请输入级别" class="layui-input">
                                </div>
                            </td>
                            <td>
                                
                            </td>
                        </tr>
                    </table>
                    <br />
                    <h2>账号信息</h2>
                    <hr class="layui-border-green">
                    <table>
                        <tr>
                            <td>
                                <label class="layui-form-label">账号</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" id="presAccount" placeholder="请输入姓名" class="layui-input">
                                </div>
                            </td>
                            <td>
                                <label class="layui-form-label">密码</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="password" id="presPass" placeholder="请输入密码" class="layui-input">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label class="layui-form-label">角色</label>
                                <div class="layui-input-block">
                                    <select id="roleId" lay-filter="aihao">
                                        <option value="">请选择</option>
                                        <option value="1">管理员</option>
                                        <option value="1">超级管理员</option>
                                        <option value="1">普通用户</option>

                                    </select>
                                </div>
                            </td>
                            <td>
                                
                            </td>
                        </tr>
                    </table>
                    <input type="button" class="layui-btn" lay-submit lay-filter="demo1" onclick="add()" value="保存" />
                    @* <button type="submit" class="layui-btn" lay-submit lay-filter="demo1" onclick="add()">保存</button> *@
                </div>
            </div>
        </div>
    </form>
</body>

</html>

<script>
    $(function () {
        bangdan();
        bangbu();
        bangjue();
    })

    function bangdan() {
        
        $.post({
            url:"",
            data: {},
            async:false,
            dataType:"json",
            contentType: "application/json",
            success:d=>{
                $(d).each(function () {
                    $("#Selectoff").append('< option value = "'+this.oid+'" > '+this.oname+' < /option>');
                })
                    
            }
        })
    }
    function bangbu() {

        $.post({
            url: "",
            data: {},
            async: false,
            dataType: "json",
            contentType: "application/json",
            success: d => {
                $(d).each(function () {
                    $("#Selectoff").append('< option value = "' + this.oid + '" > ' + this.oname + ' < /option>');
                })

            }
        })
    }
    function bangjue() {

        $.post({
            url: "",
            data: {},
            async: false,
            dataType: "json",
            contentType: "application/json",
            success: d => {
                $(d).each(function () {
                    $("#Selectoff").append('< option value = "' + this.oid + '" > ' + this.oname + ' < /option>');
                })

            }
        })
    }

    function add() {
        
        var data = {
            persName: $("#persName").val(),
            persSex: $("[name=persSex]:checked").val(),
            persCardType: $("#persCardType").val(),
            persCard: $("#persCard").val(),
            persPhone: $("#persPhone").val(),
            persEmail: $("#persEmail").val(),
            persCollege: $("#persCollege").val(),
            education: $("#education").val(),
            enterpriseId: $("#enterpriseId").val(),
            staffState: $("#staffState").val(),
            departmentId: $("#departmentId").val(),
            persEntry: $("#persEntry").val(),
            persRegular: $("#persRegular").val(),
            persFunction: $("#persFunction").val(),
            presTrain: $("#presTrain").val(),
            presLevel: $("#presLevel").val(),
            presAccount: $("#presAccount").val(),
            presPass: $("#presPass").val(),
            roleId: $("#roleId").val()
        }
        console.log(data);
        $.ajax({
            url: "http://localhost:5123/api/UsersInterface/AddPersonnel",
            type:'post',
            data: JSON.stringify(data),
            dataType: "json",
            contentType: "application/json",
            success: d => {
                if (d==0) {
                    layer.msg('保存成功');
                    location.href = "/User/UserList";
                }
                else {
                    layer.msg('保存失败');
                }
            }
        })
    }







</script>
